/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.service;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.BaseModel;

import vn.com.fis.portal.model.CategoryEntryClp;
import vn.com.fis.portal.model.CategoryVideoEntryClp;
import vn.com.fis.portal.model.UserEntryClp;
import vn.com.fis.portal.model.VideoEntryClp;
import vn.com.fis.portal.model.VideoUserEntryClp;

import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Brian Wing Shun Chan
 */
public class ClpSerializer {
	public static String getServletContextName() {
		if (Validator.isNotNull(_servletContextName)) {
			return _servletContextName;
		}

		synchronized (ClpSerializer.class) {
			if (Validator.isNotNull(_servletContextName)) {
				return _servletContextName;
			}

			try {
				ClassLoader classLoader = ClpSerializer.class.getClassLoader();

				Class<?> portletPropsClass = classLoader.loadClass(
						"com.liferay.util.portlet.PortletProps");

				Method getMethod = portletPropsClass.getMethod("get",
						new Class<?>[] { String.class });

				String portletPropsServletContextName = (String)getMethod.invoke(null,
						"LFWS-portlet-deployment-context");

				if (Validator.isNotNull(portletPropsServletContextName)) {
					_servletContextName = portletPropsServletContextName;
				}
			}
			catch (Throwable t) {
				if (_log.isInfoEnabled()) {
					_log.info(
						"Unable to locate deployment context from portlet properties");
				}
			}

			if (Validator.isNull(_servletContextName)) {
				try {
					String propsUtilServletContextName = PropsUtil.get(
							"LFWS-portlet-deployment-context");

					if (Validator.isNotNull(propsUtilServletContextName)) {
						_servletContextName = propsUtilServletContextName;
					}
				}
				catch (Throwable t) {
					if (_log.isInfoEnabled()) {
						_log.info(
							"Unable to locate deployment context from portal properties");
					}
				}
			}

			if (Validator.isNull(_servletContextName)) {
				_servletContextName = "LFWS-portlet";
			}

			return _servletContextName;
		}
	}

	public static void setClassLoader(ClassLoader classLoader) {
		_classLoader = classLoader;
	}

	public static Object translateInput(BaseModel<?> oldModel) {
		Class<?> oldModelClass = oldModel.getClass();

		String oldModelClassName = oldModelClass.getName();

		if (oldModelClassName.equals(CategoryEntryClp.class.getName())) {
			return translateInputCategoryEntry(oldModel);
		}

		if (oldModelClassName.equals(CategoryVideoEntryClp.class.getName())) {
			return translateInputCategoryVideoEntry(oldModel);
		}

		if (oldModelClassName.equals(UserEntryClp.class.getName())) {
			return translateInputUserEntry(oldModel);
		}

		if (oldModelClassName.equals(VideoEntryClp.class.getName())) {
			return translateInputVideoEntry(oldModel);
		}

		if (oldModelClassName.equals(VideoUserEntryClp.class.getName())) {
			return translateInputVideoUserEntry(oldModel);
		}

		return oldModel;
	}

	public static Object translateInput(List<Object> oldList) {
		List<Object> newList = new ArrayList<Object>(oldList.size());

		for (int i = 0; i < oldList.size(); i++) {
			Object curObj = oldList.get(i);

			newList.add(translateInput(curObj));
		}

		return newList;
	}

	public static Object translateInputCategoryEntry(BaseModel<?> oldModel) {
		CategoryEntryClp oldCplModel = (CategoryEntryClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("vn.com.fis.portal.model.impl.CategoryEntryImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setCategoryId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getCategoryId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setCategoryName",
						new Class[] { String.class });

				String value1 = oldCplModel.getCategoryName();

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setDescription",
						new Class[] { String.class });

				String value2 = oldCplModel.getDescription();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setStatus",
						new Class[] { Integer.TYPE });

				Integer value3 = new Integer(oldCplModel.getStatus());

				method3.invoke(newModel, value3);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputCategoryVideoEntry(BaseModel<?> oldModel) {
		CategoryVideoEntryClp oldCplModel = (CategoryVideoEntryClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("vn.com.fis.portal.model.impl.CategoryVideoEntryImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setCategoryVideoId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getCategoryVideoId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setCategoryId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getCategoryId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setVideoId",
						new Class[] { Long.TYPE });

				Long value2 = new Long(oldCplModel.getVideoId());

				method2.invoke(newModel, value2);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputUserEntry(BaseModel<?> oldModel) {
		UserEntryClp oldCplModel = (UserEntryClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("vn.com.fis.portal.model.impl.UserEntryImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getUserId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value1 = oldCplModel.getUserName();

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setMobilePhone",
						new Class[] { String.class });

				String value2 = oldCplModel.getMobilePhone();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setGroupId",
						new Class[] { Long.TYPE });

				Long value3 = new Long(oldCplModel.getGroupId());

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setCompanyId",
						new Class[] { Long.TYPE });

				Long value4 = new Long(oldCplModel.getCompanyId());

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setServiceId",
						new Class[] { Long.TYPE });

				Long value5 = new Long(oldCplModel.getServiceId());

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setServiceStatus",
						new Class[] { Integer.TYPE });

				Integer value6 = new Integer(oldCplModel.getServiceStatus());

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setServiceStartDate",
						new Class[] { Date.class });

				Date value7 = oldCplModel.getServiceStartDate();

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setServiceStopDate",
						new Class[] { Date.class });

				Date value8 = oldCplModel.getServiceStopDate();

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setServicePackageId",
						new Class[] { Long.TYPE });

				Long value9 = new Long(oldCplModel.getServicePackageId());

				method9.invoke(newModel, value9);

				Method method10 = newModelClass.getMethod("setServicePackageStatus",
						new Class[] { Integer.TYPE });

				Integer value10 = new Integer(oldCplModel.getServicePackageStatus());

				method10.invoke(newModel, value10);

				Method method11 = newModelClass.getMethod("setServicePackageStartDate",
						new Class[] { Date.class });

				Date value11 = oldCplModel.getServicePackageStartDate();

				method11.invoke(newModel, value11);

				Method method12 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value12 = oldCplModel.getCreateDate();

				method12.invoke(newModel, value12);

				Method method13 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value13 = oldCplModel.getModifiedDate();

				method13.invoke(newModel, value13);

				Method method14 = newModelClass.getMethod("setDescription",
						new Class[] { String.class });

				String value14 = oldCplModel.getDescription();

				method14.invoke(newModel, value14);

				Method method15 = newModelClass.getMethod("setStatus",
						new Class[] { Integer.TYPE });

				Integer value15 = new Integer(oldCplModel.getStatus());

				method15.invoke(newModel, value15);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputVideoEntry(BaseModel<?> oldModel) {
		VideoEntryClp oldCplModel = (VideoEntryClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("vn.com.fis.portal.model.impl.VideoEntryImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setVideoId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getVideoId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setVideoName",
						new Class[] { String.class });

				String value1 = oldCplModel.getVideoName();

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setVideoUrl",
						new Class[] { String.class });

				String value2 = oldCplModel.getVideoUrl();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setFolderId",
						new Class[] { Long.TYPE });

				Long value3 = new Long(oldCplModel.getFolderId());

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setSize",
						new Class[] { Long.TYPE });

				Long value4 = new Long(oldCplModel.getSize());

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setFormat",
						new Class[] { String.class });

				String value5 = oldCplModel.getFormat();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setDescription",
						new Class[] { String.class });

				String value6 = oldCplModel.getDescription();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setAccessModifier",
						new Class[] { Integer.TYPE });

				Integer value7 = new Integer(oldCplModel.getAccessModifier());

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setSmallImageUrl",
						new Class[] { String.class });

				String value8 = oldCplModel.getSmallImageUrl();

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setLargeImageUrl",
						new Class[] { String.class });

				String value9 = oldCplModel.getLargeImageUrl();

				method9.invoke(newModel, value9);

				Method method10 = newModelClass.getMethod("setStatus",
						new Class[] { Integer.TYPE });

				Integer value10 = new Integer(oldCplModel.getStatus());

				method10.invoke(newModel, value10);

				Method method11 = newModelClass.getMethod("setUploaderId",
						new Class[] { Long.TYPE });

				Long value11 = new Long(oldCplModel.getUploaderId());

				method11.invoke(newModel, value11);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputVideoUserEntry(BaseModel<?> oldModel) {
		VideoUserEntryClp oldCplModel = (VideoUserEntryClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("vn.com.fis.portal.model.impl.VideoUserEntryImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setVideoUserId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getVideoUserId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setVideoId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getVideoId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value2 = new Long(oldCplModel.getUserId());

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setOriginCode",
						new Class[] { Integer.TYPE });

				Integer value3 = new Integer(oldCplModel.getOriginCode());

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setDate_",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getDate_();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setStartDate",
						new Class[] { Date.class });

				Date value5 = oldCplModel.getStartDate();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setEndDate",
						new Class[] { Date.class });

				Date value6 = oldCplModel.getEndDate();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setSenderId",
						new Class[] { Long.TYPE });

				Long value7 = new Long(oldCplModel.getSenderId());

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setServiceActive",
						new Class[] { Integer.TYPE });

				Integer value8 = new Integer(oldCplModel.getServiceActive());

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setStatus",
						new Class[] { Integer.TYPE });

				Integer value9 = new Integer(oldCplModel.getStatus());

				method9.invoke(newModel, value9);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInput(Object obj) {
		if (obj instanceof BaseModel<?>) {
			return translateInput((BaseModel<?>)obj);
		}
		else if (obj instanceof List<?>) {
			return translateInput((List<Object>)obj);
		}
		else {
			return obj;
		}
	}

	public static Object translateOutput(BaseModel<?> oldModel) {
		Class<?> oldModelClass = oldModel.getClass();

		String oldModelClassName = oldModelClass.getName();

		if (oldModelClassName.equals(
					"vn.com.fis.portal.model.impl.CategoryEntryImpl")) {
			return translateOutputCategoryEntry(oldModel);
		}

		if (oldModelClassName.equals(
					"vn.com.fis.portal.model.impl.CategoryVideoEntryImpl")) {
			return translateOutputCategoryVideoEntry(oldModel);
		}

		if (oldModelClassName.equals(
					"vn.com.fis.portal.model.impl.UserEntryImpl")) {
			return translateOutputUserEntry(oldModel);
		}

		if (oldModelClassName.equals(
					"vn.com.fis.portal.model.impl.VideoEntryImpl")) {
			return translateOutputVideoEntry(oldModel);
		}

		if (oldModelClassName.equals(
					"vn.com.fis.portal.model.impl.VideoUserEntryImpl")) {
			return translateOutputVideoUserEntry(oldModel);
		}

		return oldModel;
	}

	public static Object translateOutput(List<Object> oldList) {
		List<Object> newList = new ArrayList<Object>(oldList.size());

		for (int i = 0; i < oldList.size(); i++) {
			Object curObj = oldList.get(i);

			newList.add(translateOutput(curObj));
		}

		return newList;
	}

	public static Object translateOutput(Object obj) {
		if (obj instanceof BaseModel<?>) {
			return translateOutput((BaseModel<?>)obj);
		}
		else if (obj instanceof List<?>) {
			return translateOutput((List<Object>)obj);
		}
		else {
			return obj;
		}
	}

	public static Object translateOutputCategoryEntry(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				CategoryEntryClp newModel = new CategoryEntryClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getCategoryId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setCategoryId(value0);

				Method method1 = oldModelClass.getMethod("getCategoryName");

				String value1 = (String)method1.invoke(oldModel, (Object[])null);

				newModel.setCategoryName(value1);

				Method method2 = oldModelClass.getMethod("getDescription");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setDescription(value2);

				Method method3 = oldModelClass.getMethod("getStatus");

				Integer value3 = (Integer)method3.invoke(oldModel,
						(Object[])null);

				newModel.setStatus(value3);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputCategoryVideoEntry(
		BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				CategoryVideoEntryClp newModel = new CategoryVideoEntryClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getCategoryVideoId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setCategoryVideoId(value0);

				Method method1 = oldModelClass.getMethod("getCategoryId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setCategoryId(value1);

				Method method2 = oldModelClass.getMethod("getVideoId");

				Long value2 = (Long)method2.invoke(oldModel, (Object[])null);

				newModel.setVideoId(value2);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputUserEntry(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				UserEntryClp newModel = new UserEntryClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getUserId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setUserId(value0);

				Method method1 = oldModelClass.getMethod("getUserName");

				String value1 = (String)method1.invoke(oldModel, (Object[])null);

				newModel.setUserName(value1);

				Method method2 = oldModelClass.getMethod("getMobilePhone");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setMobilePhone(value2);

				Method method3 = oldModelClass.getMethod("getGroupId");

				Long value3 = (Long)method3.invoke(oldModel, (Object[])null);

				newModel.setGroupId(value3);

				Method method4 = oldModelClass.getMethod("getCompanyId");

				Long value4 = (Long)method4.invoke(oldModel, (Object[])null);

				newModel.setCompanyId(value4);

				Method method5 = oldModelClass.getMethod("getServiceId");

				Long value5 = (Long)method5.invoke(oldModel, (Object[])null);

				newModel.setServiceId(value5);

				Method method6 = oldModelClass.getMethod("getServiceStatus");

				Integer value6 = (Integer)method6.invoke(oldModel,
						(Object[])null);

				newModel.setServiceStatus(value6);

				Method method7 = oldModelClass.getMethod("getServiceStartDate");

				Date value7 = (Date)method7.invoke(oldModel, (Object[])null);

				newModel.setServiceStartDate(value7);

				Method method8 = oldModelClass.getMethod("getServiceStopDate");

				Date value8 = (Date)method8.invoke(oldModel, (Object[])null);

				newModel.setServiceStopDate(value8);

				Method method9 = oldModelClass.getMethod("getServicePackageId");

				Long value9 = (Long)method9.invoke(oldModel, (Object[])null);

				newModel.setServicePackageId(value9);

				Method method10 = oldModelClass.getMethod(
						"getServicePackageStatus");

				Integer value10 = (Integer)method10.invoke(oldModel,
						(Object[])null);

				newModel.setServicePackageStatus(value10);

				Method method11 = oldModelClass.getMethod(
						"getServicePackageStartDate");

				Date value11 = (Date)method11.invoke(oldModel, (Object[])null);

				newModel.setServicePackageStartDate(value11);

				Method method12 = oldModelClass.getMethod("getCreateDate");

				Date value12 = (Date)method12.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value12);

				Method method13 = oldModelClass.getMethod("getModifiedDate");

				Date value13 = (Date)method13.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value13);

				Method method14 = oldModelClass.getMethod("getDescription");

				String value14 = (String)method14.invoke(oldModel,
						(Object[])null);

				newModel.setDescription(value14);

				Method method15 = oldModelClass.getMethod("getStatus");

				Integer value15 = (Integer)method15.invoke(oldModel,
						(Object[])null);

				newModel.setStatus(value15);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputVideoEntry(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				VideoEntryClp newModel = new VideoEntryClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getVideoId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setVideoId(value0);

				Method method1 = oldModelClass.getMethod("getVideoName");

				String value1 = (String)method1.invoke(oldModel, (Object[])null);

				newModel.setVideoName(value1);

				Method method2 = oldModelClass.getMethod("getVideoUrl");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setVideoUrl(value2);

				Method method3 = oldModelClass.getMethod("getFolderId");

				Long value3 = (Long)method3.invoke(oldModel, (Object[])null);

				newModel.setFolderId(value3);

				Method method4 = oldModelClass.getMethod("getSize");

				Long value4 = (Long)method4.invoke(oldModel, (Object[])null);

				newModel.setSize(value4);

				Method method5 = oldModelClass.getMethod("getFormat");

				String value5 = (String)method5.invoke(oldModel, (Object[])null);

				newModel.setFormat(value5);

				Method method6 = oldModelClass.getMethod("getDescription");

				String value6 = (String)method6.invoke(oldModel, (Object[])null);

				newModel.setDescription(value6);

				Method method7 = oldModelClass.getMethod("getAccessModifier");

				Integer value7 = (Integer)method7.invoke(oldModel,
						(Object[])null);

				newModel.setAccessModifier(value7);

				Method method8 = oldModelClass.getMethod("getSmallImageUrl");

				String value8 = (String)method8.invoke(oldModel, (Object[])null);

				newModel.setSmallImageUrl(value8);

				Method method9 = oldModelClass.getMethod("getLargeImageUrl");

				String value9 = (String)method9.invoke(oldModel, (Object[])null);

				newModel.setLargeImageUrl(value9);

				Method method10 = oldModelClass.getMethod("getStatus");

				Integer value10 = (Integer)method10.invoke(oldModel,
						(Object[])null);

				newModel.setStatus(value10);

				Method method11 = oldModelClass.getMethod("getUploaderId");

				Long value11 = (Long)method11.invoke(oldModel, (Object[])null);

				newModel.setUploaderId(value11);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputVideoUserEntry(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				VideoUserEntryClp newModel = new VideoUserEntryClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getVideoUserId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setVideoUserId(value0);

				Method method1 = oldModelClass.getMethod("getVideoId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setVideoId(value1);

				Method method2 = oldModelClass.getMethod("getUserId");

				Long value2 = (Long)method2.invoke(oldModel, (Object[])null);

				newModel.setUserId(value2);

				Method method3 = oldModelClass.getMethod("getOriginCode");

				Integer value3 = (Integer)method3.invoke(oldModel,
						(Object[])null);

				newModel.setOriginCode(value3);

				Method method4 = oldModelClass.getMethod("getDate_");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setDate_(value4);

				Method method5 = oldModelClass.getMethod("getStartDate");

				Date value5 = (Date)method5.invoke(oldModel, (Object[])null);

				newModel.setStartDate(value5);

				Method method6 = oldModelClass.getMethod("getEndDate");

				Date value6 = (Date)method6.invoke(oldModel, (Object[])null);

				newModel.setEndDate(value6);

				Method method7 = oldModelClass.getMethod("getSenderId");

				Long value7 = (Long)method7.invoke(oldModel, (Object[])null);

				newModel.setSenderId(value7);

				Method method8 = oldModelClass.getMethod("getServiceActive");

				Integer value8 = (Integer)method8.invoke(oldModel,
						(Object[])null);

				newModel.setServiceActive(value8);

				Method method9 = oldModelClass.getMethod("getStatus");

				Integer value9 = (Integer)method9.invoke(oldModel,
						(Object[])null);

				newModel.setStatus(value9);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	private static Log _log = LogFactoryUtil.getLog(ClpSerializer.class);
	private static ClassLoader _classLoader;
	private static String _servletContextName;
}